package oop3.Task;

public class Cat {
    String name;
    int weight;
    int energy; //体力

    public Cat(String name, int weight, int energy) {
        this.name = name;
        this.weight = weight;
        this.energy = energy;
    }

    public void grab(Mouse mouse) {
        System.out.println("猫抓老鼠:");
        if (mouse.energy > 100) {
            System.out.println("老鼠体力大跑得快，没抓住");
        } else {
            System.out.println("抓住老鼠" + mouse.name + ",咬死");
            energy += mouse.energy;   //猫的体力加上老鼠的体力
            mouse.energy = 0;
        }
        System.out.println();
        mouse.show();
        show();
    }

    public void show() {
        System.out.println("猫的名字:" + name + ",猫的体重:" + weight + "斤,猫的体力:" + energy);
    }
}

